﻿using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;

namespace Batman.RefiningPharmacist.Migrations
{
    public partial class _201810281 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Composite",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    CompositeName = table.Column<string>(nullable: true),
                    CreatorId = table.Column<string>(nullable: true),
                    CreateAt = table.Column<DateTime>(nullable: false),
                    IsDeleted = table.Column<bool>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Composite", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "CompositeItem",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    CompositeItemName = table.Column<string>(nullable: true),
                    CompositeItemAmount = table.Column<float>(nullable: false),
                    CreateBy = table.Column<int>(nullable: false),
                    CreateAt = table.Column<DateTime>(nullable: false),
                    IsDeleted = table.Column<bool>(nullable: false),
                    DeleteBy = table.Column<int>(nullable: true),
                    DeleteAt = table.Column<DateTime>(nullable: true),
                    CompositeId = table.Column<int>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_CompositeItem", x => x.Id);
                    table.ForeignKey(
                        name: "FK_CompositeItem_Composite_CompositeId",
                        column: x => x.CompositeId,
                        principalTable: "Composite",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateIndex(
                name: "IX_CompositeItem_CompositeId",
                table: "CompositeItem",
                column: "CompositeId");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "CompositeItem");

            migrationBuilder.DropTable(
                name: "Composite");
        }
    }
}
